package com.wdz.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.api.exception.NacosException;
import com.wdz.http.Response;
import com.wdz.service.NacosConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ConfigController {
    @Autowired
    private NacosConfigService nacosConfigService;

    @Value("${spring.profiles.active}")
    private String tenant;
    @GetMapping("/api/getHt_nav")
    public Response test() throws NacosException {
            JSONArray content = JSONArray.parseArray(nacosConfigService.getConfig("ht_nav","blogBackstage",tenant));
            return Response.success(content);
    }
    @GetMapping("/api/getHtConfig")
    public Response getHtConfig() throws NacosException {
        return Response.success(JSONObject.parse(nacosConfigService.getConfig("ht_config","blogBackstage",tenant)));
    }
}
